import { toast } from "@/utils/toast";
import { useClipboard } from "@vueuse/core";
import clipboard from "vue-clipboard3";

export const handleCopy = async (text: string) => {
  const { toClipboard } = clipboard();
  await toClipboard(text || "复制");
  toast.success("复制成功");
};

export const useUtils = () => {
  const copyText = async (text: string) => {
    const { copy, isSupported, copied } = useClipboard();
    if (isSupported) {
      await copy(text);
    }
    return copied;
  };
  return {
    copyText
  };
};
